#include<iostream>
using namespace std;

class Person
{
public:
    Person()
    {
        cout << "Person的默认构造函数" << endl;
    }

    Person(int a,int h)
    {
        m_age = a;
        height = new int(h);
        cout << "Person的有参构造函数" << endl;
    }

    Person(const Person& p)
    {
        m_age = p.m_age;
        height = new int(*p.height);
        cout << "Person的拷贝构造函数" << endl;
    }

    ~Person()
    {
        if(!height)
        {
            delete height;
            height = NULL;
        }
        cout << "Person的析构函数" << endl;
    }

    int m_age;
    int* height;
};

void test()
{
    Person p(27, 172);
    Person p1(p);

    cout << "p的年龄为:" << p.m_age << "  p的身高为:" << *p.height << endl;
    cout << "p1的年龄为:" << p1.m_age << "  p1的身高为:" << *p1.height << endl;
}

int main()
{
    test();

    return 0;
}
